﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace homeIMSService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
    public class homeIMSService : IhomeIMSService
    {
        //create private instance of service connection to manage users logged in
        private Model.service service;

        public homeIMSService()
        {
            service = new Model.service();
        }

        public userInfo Login(string userName, string password)
        {
           return service.login(userName, password);
        }

        public int register(userInfo userInformation)
        {
            //get result for register
            int result = service.register(userInformation);

            return result;
        }

        public assetList getUserAssets(int userID)
        {
            assetList assets = null ;
            foreach (Model.user user in service.ActiveUsers)
            {
                if (user.UserID == userID)
                {
                    assets = user.getUserAssets();
                }
            }
            return assets;
        }

        public bool CheckUserName(string userName)
        {
            return service.CheckUserName(userName);
        }

        public assetTypeList getAssetTypes()
        {
            return service.getAssetTypes();
        }

        public assetQualityList getQualityList()
        {
            return service.getQualityList();
        }

        
    }
}
